﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace DAL.DBManagers
{
    public class CurrenciesManager : BaseManager<Currency>
    {
        public CurrenciesManager()
            : base()
        {
        }

        public override IEnumerable<Currency> GetAll()
        {
            return (_context as PortEntities).Currencies.Include("CurrencyType").Where(w => w.IsActive).OrderByDescending(o => o.CurrencyDate).ToList();
        }

        public override List<Currency> GetAll(string sortBy)
        {
            List<Currency> prodList = (_context as PortEntities).Currencies.Include("CurrencyType").Where(w => w.IsActive).ToList();
            if (sortBy != "")
            {
                DAL.Models.GenericComparer<Currency> cmp = new DAL.Models.GenericComparer<Currency>(sortBy);
                prodList.Sort(cmp);
            }
            return prodList;
        }
    }
}
